home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / amigaoscd / amigapluscd / AP-Website / forum / wbboard / board.php < prev    next >
Text File  |  2002-03-15  |  9KB  |  193 lines

  1. <? 
  2. require("_functions.php");
  3. require("_header.php");
  4. require("_board_jump.php");
  5.  
  6. $boardcache=array();
  7. $permissioncache=array();
  8. $modcache=array();
  9.  
  10. if($boardid == -1) {
  11.     eval ("\$output = \"".gettemplate("error3")."\";");
  12.     eval("dooutput(\"".gettemplate("action_error")."\");");
  13.     exit;
  14. }
  15. if($boardid == "home") {
  16.     header("LOCATION: main.php$session2");
  17.     exit;
  18. }
  19. if($boardid == "pm") {
  20.     header("LOCATION: pms.php$session2");
  21.     exit;
  22. }
  23. if($boardid == "search") {
  24.     header("LOCATION: search.php$session2");
  25.     exit;
  26. }
  27. if($boardid == "profil") {
  28.     header("LOCATION: profile.php$session2");
  29.     exit;
  30. }
  31.  
  32. $binfo = $db_zugriff->query_first("SELECT * FROM bb".$n."_boards WHERE boardid='$boardid'");
  33. $binfo[boardname] = editDBdata($binfo[boardname]);
  34.  
  35. $result = $db_zugriff->query("
  36.     SELECT
  37.     bb".$n."_boards.*,
  38.     bb".$n."_posts.threadparentid,
  39.     bb".$n."_posts.userid,
  40.     bb".$n."_posts.posttime,
  41.     bb".$n."_threads.threadname,
  42.     bb".$n."_threads.topicicon,
  43.     bb".$n."_threads.boardparentid as parentid,
  44.     bb".$n."_user_table.username    
  45.     FROM bb".$n."_boards
  46.     LEFT JOIN bb".$n."_posts ON (bb".$n."_posts.postid=bb".$n."_boards.lastpostid) 
  47.     LEFT JOIN bb".$n."_threads ON (bb".$n."_threads.threadid=bb".$n."_posts.threadparentid) 
  48.     LEFT JOIN bb".$n."_user_table ON (bb".$n."_user_table.userid=bb".$n."_posts.userid) 
  49.     WHERE bb".$n."_boards.boardparentid>0
  50.     ORDER by boardparentid ASC, sort ASC");
  51. while ($row = $db_zugriff->fetch_array($result)) $boardcache[$row[boardparentid]][$row[sort]][$row[boardid]] = $row;
  52. $result = $db_zugriff->query("SELECT boardid FROM bb".$n."_object2board WHERE objectid = '$user_group' AND boardpermission = 1");
  53. while ($row = $db_zugriff->fetch_array($result)) $permissioncache[$row[boardid]] = 1;
  54. $result = $db_zugriff->query("SELECT userid, username, boardid FROM bb".$n."_object2board LEFT JOIN bb".$n."_user_table ON (bb".$n."_object2board.objectid = bb".$n."_user_table.userid) WHERE mod = 1 ORDER BY username ASC");
  55. while ($row = $db_zugriff->fetch_array($result)) $modcache[$row[boardid]][] = $row;
  56. $board_boardbit = makeforumbit($boardid);
  57. $db_zugriff->free_result($result);
  58. if($board_boardbit) eval ("\$subboards .= \"".gettemplate("board_subboards")."\";");
  59. $navi_chain = makenavichain("board",$boardid);
  60. if(!$binfo[isboard]) {
  61.     eval("dooutput(\"".gettemplate("board_cat")."\");");
  62.     exit;
  63. }
  64. $time = time()+$timeoffset*3600;
  65. $result = $db_zugriff->query("SELECT announcementid, topic, bb".$n."_announcements.userid, username FROM bb".$n."_announcements LEFT JOIN bb".$n."_user_table ON (bb".$n."_user_table.userid=bb".$n."_announcements.userid) WHERE starttime <= '$time' AND endtime >= '$time' AND (boardid=0 OR boardid='$boardid') ORDER BY starttime DESC");
  66. while($row = $db_zugriff->fetch_array($result)) {
  67.     $row[topic] = editDBdata($row[topic]);
  68.     eval ("\$board_threadbit .= \"".gettemplate("announcementbit")."\";");
  69. }
  70. $db_zugriff->free_result($result);
  71.  
  72. switch($sortfield) {
  73.  case "threadname"; break;
  74.  case "starttime": break;    
  75.  case "replies": break;    
  76.  case "views": break;    
  77.  case "authorid": break;    
  78.  default: $sortfield = "timelastreply"; break;     
  79. }
  80.  
  81. switch($sortorder) {
  82.  case "ASC"; break;
  83.  default: $sortorder = "DESC"; break;     
  84. }
  85.  
  86. if(!$daysprune && !$prunedays) $daysprune = $default_daysprune;
  87. if(!$daysprune && $prunedays) $daysprune = $prunedays;
  88. if($daysprune!=1000) $date = time()-(86400*intval($daysprune));
  89. else $date="";
  90.  
  91. $anzahl = $db_zugriff->query_first("SELECT COUNT(threadid)as anzahl FROM bb".$n."_threads WHERE (boardparentid='$boardid' OR putoffid='$boardid') AND (timelastreply>='$date' OR important='1')");
  92. $anzahl = $anzahl[anzahl];
  93. if(!$page) $page=1;
  94. $getthreadids=$db_zugriff->query("SELECT threadid FROM bb".$n."_threads WHERE (boardparentid='$boardid' OR putoffid='$boardid') AND (timelastreply>='$date' OR important='1') ORDER by important DESC, $sortfield $sortorder LIMIT ".($tproseite*($page-1)).",".($tproseite));
  95. while($row=$db_zugriff->fetch_array($getthreadids)) $threadids.=",".$row[threadid];
  96.  
  97. $thread_result = $db_zugriff->query("SELECT bb".$n."_threads.*, bb".$n."_user_table.username AS lastpostername FROM bb".$n."_threads
  98.  LEFT JOIN bb".$n."_user_table ON (bb".$n."_user_table.userid=bb".$n."_threads.lastposterid)
  99.  WHERE threadid IN (0$threadids)
  100.  ORDER by important DESC, $sortfield $sortorder");
  101. $pages=ceil($anzahl/$tproseite);
  102.  
  103. while($threads = $db_zugriff->fetch_array($thread_result)) {                        
  104.         
  105.     unset($folder_image);
  106.     unset($thread_link);
  107.     unset($rate);
  108.     unset($anonymous_lp);
  109.     unset($anonymous);
  110.     unset($thread_starter);
  111.     unset($lastauthor);
  112.     
  113.     $sthreadname = "sthread_".$threads[threadid];    
  114.     if($boardid == $threads[putoffid]) $folder_image = "<img src=\"images/movedfolder.gif\">";
  115.     else {
  116.         if($old_time <= $threads[timelastreply] && $$sthreadname < $threads[timelastreply]) $folder_image .= "new";        
  117.         if($threads[replies] > $hotthread_reply || $threads[views] > $hotthread_view) $folder_image .= "hot";
  118.         if($threads[flags]==1) $folder_image .= "lock";
  119.         $folder_image = "<img src=\"images/".$folder_image."folder.gif\">";
  120.     }
  121.     if($threads[topicicon]) $posticon = "<img src=\"$threads[topicicon]\">";
  122.     else $posticon = " ";
  123.         
  124.     if($old_time <= $threads[timelastreply] && $$sthreadname < $threads[timelastreply]) eval ("\$thread_link .= \"".gettemplate("board_gofirstnew")."\";");
  125.     $thread_link .= "<font size=2 face=\"{font}\"><b>";
  126.     if($boardid == $threads[putoffid]) eval ("\$thread_link .= \"".gettemplate("board_moved")."\";");
  127.     elseif($threads[important]) eval ("\$thread_link .= \"".gettemplate("board_important")."\";");
  128.     if($threads[pquestion]) eval ("\$thread_link .= \"".gettemplate("board_poll")."\";");
  129.     $thread_link .= "<a class=\"link\" href=\"thread.php?threadid=$threads[threadid]&boardid=$threads[boardparentid]&styleid=$styleid$session\">".prepare_topic($threads[threadname])."</a></b></font>";
  130.     if(($threads[replies]+1)/$eproseite > 1) $thread_link .= "<font size=1 face=\"$font\"> ( <img src=\"images/multipage.gif\"> <a class=\"link\" href=\"thread.php?threadid=$threads[threadid]&boardid=$threads[boardparentid]&styleid=$styleid$session&page=1\">1</a> <a class=\"link\" href=\"thread.php?threadid=$threads[threadid]&boardid=$threads[boardparentid]&styleid=$styleid$session&page=2\">2</a> ";
  131.     if(($threads[replies]+1)/$eproseite > 2) $thread_link .= "<a class=\"link\" href=\"thread.php?threadid=$threads[threadid]&boardid=$threads[boardparentid]&styleid=$styleid$session&page=3\">3</a> ";
  132.     if(($threads[replies]+1)/$eproseite > 3) $thread_link .= "<a class=\"link\" href=\"thread.php?threadid=".$threads[threadid]."&boardid=$threads[boardparentid]&styleid=$styleid$session&page=4\">4</a> ";
  133.     if(($threads[replies]+1)/$eproseite > 4) {
  134.         $pagesx=ceil(($threads[replies]+1)/$eproseite);
  135.         eval ("\$thread_link .= \"".gettemplate("board_lastpage")."\";");
  136.     }
  137.     if(($threads[replies]+1)/$eproseite > 1) $thread_link .= ")</font>";
  138.         
  139.     $starttime = formatdate($threads[starttime],$longdateformat,1);
  140.     if($threads[authorid]) $thread_starter = $threads[author];
  141.     else eval ("\$anonymous = \"".gettemplate("lg_anonymous")."\";");
  142.     $lastposttime = formatdate($threads[timelastreply],$longdateformat,1);
  143.     $lastauthorid = $threads[lastposterid];
  144.     if($lastauthorid) $lastauthor = $threads[lastpostername];
  145.     else eval ("\$anonymous_lp = \"".gettemplate("lg_anonymous")."\";");
  146.     eval ("\$last_post = \"".gettemplate("board_lastpost")."\";");
  147.                 
  148.     if($threads[rated] && $threads[rate_points]) {
  149.         $j = round($threads[rate_points]/$threads[rated]);
  150.         for ($j; $j > 0; $j--) $rate .= "<img src=\"images/star.gif\" border=0>";
  151.     }
  152.     else $rate = " ";
  153.         
  154.     eval ("\$board_threadbit .= \"".gettemplate("board_threadbit")."\";");
  155. }
  156. $db_zugriff->free_result($thread_result);
  157. if($pages>1) $page_link = makepagelink("board.php?boardid=$boardid$session", $page, $pages);
  158. if($mods = getMod($boardid)) eval ("\$mods = \"".gettemplate("board_moderate")."\";");
  159.  
  160. $l_threads = 1+($page-1)*$tproseite;
  161. $h_threads = $page*$tproseite;
  162. if($h_threads > $anzahl) $h_threads = $anzahl;
  163. $all_threads = $anzahl;
  164.  
  165. if($sortfield == "threadname") $f_select[0] = "selected";
  166. if($sortfield == "timelastreply") $f_select[1] = "selected";
  167. if($sortfield == "replies") $f_select[2] = "selected";
  168. if($sortfield == "views") $f_select[3] = "selected";
  169. if($sortfield == "author") $f_select[4] = "selected";
  170. if($sortfield == "starttime") $f_select[5] = "selected";
  171.  
  172. if($sortorder == "ASC") $o_select[0] = "selected";
  173. if($sortorder == "DESC") $o_select[1] = "selected";
  174.  
  175. if($daysprune == "1") $d_select[0] = "selected";
  176. if($daysprune == "2") $d_select[1] = "selected";
  177. if($daysprune == "5") $d_select[2] = "selected";
  178. if($daysprune == "10") $d_select[3] = "selected";
  179. if($daysprune == "20") $d_select[4] = "selected";
  180. if($daysprune == "30") $d_select[5] = "selected";
  181. if($daysprune == "45") $d_select[6] = "selected";
  182. if($daysprune == "60") $d_select[7] = "selected";
  183. if($daysprune == "75") $d_select[8] = "selected";
  184. if($daysprune == "100") $d_select[9] = "selected";
  185. if($daysprune == "365") $d_select[10] = "selected";
  186. if($daysprune == "1000") $d_select[11] = "selected";
  187.  
  188. if($board_threadbit) {
  189.     eval ("\$threads_order  .= \"".gettemplate("board_threads_order")."\";");
  190.     eval("dooutput(\"".gettemplate("board")."\");");
  191. }
  192. else eval("dooutput(\"".gettemplate("board_no_threads")."\");");
  193. ?>